import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class InvertedIndex {

	Map<String, Integer> promoMap;
	ArrayList<String> PROMOS;
	Map<String, ArrayList<String>> tweetMap;

	public Map<String, Integer> getPromoMap() {
		return promoMap;
	}

	public ArrayList<String> getPromoList() {
		return PROMOS;
	}

	public Map<String, ArrayList<String>> getMap() {
		return tweetMap;
	}

	public Map<String, ArrayList<String>> buildMap(List<String> tweetList) {
		promoMap = new HashMap<String, Integer>();
		promoMap.put("Jake", 0);
		promoMap.put("Commercial", 0);
		promoMap.put("Good Neighbor", 0);
		promoMap.put("Hot Tub", 0);

		tweetMap = new HashMap<String, ArrayList<String>>();
		ArrayList<String> AUTO = new ArrayList<String>();
		PROMOS = new ArrayList<String>();
		ArrayList<String> HOME = new ArrayList<String>();
		ArrayList<String> BANK = new ArrayList<String>();
		ArrayList<String> LIFE = new ArrayList<String>();
		ArrayList<String> OTHER = new ArrayList<String>();
		tweetMap.put("Auto", AUTO);
		tweetMap.put("Promotions", PROMOS);
		tweetMap.put("Home", HOME);
		tweetMap.put("Bank", BANK);
		tweetMap.put("Life", LIFE);
		tweetMap.put("Other", OTHER);

		for (String tweet : tweetList) {
			boolean other = true;
			String tweetUPPER = tweet.toUpperCase();
			if (tweetUPPER.contains("AUTO") || tweetUPPER.contains("CAR")
					|| tweetUPPER.contains("TRUCK")
					|| tweetUPPER.contains("VAN")
					|| tweetUPPER.contains("AUTOMOBILE")
					|| tweetUPPER.contains("ENGINE")
					|| tweetUPPER.contains("MOTOR")
					|| tweetUPPER.contains("VEHICLE")
					|| tweetUPPER.contains("CRASH")
					|| tweetUPPER.contains("ACCIDENT")
					|| tweetUPPER.contains("CLAIM")) {
				AUTO.add(tweet);
				other = false;
			}
			if (tweetUPPER.contains("JAKE")) {
				PROMOS.add(tweet);
				other = false;
				promoMap.put("Jake", promoMap.get("Jake") + 1);
			} else if (tweetUPPER.contains("GOOD NEIGHBOR")) {
				PROMOS.add(tweet);
				other = false;
				promoMap.put("Good Neighbor", promoMap.get("Good Neighbor") + 1);
			} else if (tweetUPPER.contains("GOOD NHBR")) {
				PROMOS.add(tweet);
				other = false;
				promoMap.put("Good Neighbor", promoMap.get("Good Neighbor") + 1);
			} else if (tweetUPPER.contains("GOODNEIGHBOR")) {
				PROMOS.add(tweet);
				other = false;
				promoMap.put("Good Neighbor", promoMap.get("Good Neighbor") + 1);
			} else if (tweetUPPER.contains("HOTTUB")) {
				PROMOS.add(tweet);
				other = false;
				promoMap.put("Hot Tub", promoMap.get("Hot Tub") + 1);
			} else if (tweetUPPER.contains("HOT TUB")) {
				PROMOS.add(tweet);
				other = false;
				promoMap.put("Hot Tub", promoMap.get("Hot Tub") + 1);
			} else if (tweetUPPER.contains("NEIGHBOR")) {
				PROMOS.add(tweet);
				other = false;
				promoMap.put("Good Neighbor", promoMap.get("Good Neighbor") + 1);
			} else if (tweetUPPER.contains("IS THERE")) {
				PROMOS.add(tweet);
				other = false;
				promoMap.put("Good Neighbor", promoMap.get("Good Neighbor") + 1);
			} else if (tweetUPPER.contains("COMMERCIAL")) {
				PROMOS.add(tweet);
				other = false;
				promoMap.put("Commercial", promoMap.get("Commercial") + 1);
			} else if (tweetUPPER.contains("LIKE A GOOD")) {
				PROMOS.add(tweet);
				other = false;
				promoMap.put("Good Neighbor", promoMap.get("Good Neighbor") + 1);
			} else if (tweetUPPER.contains("AD")) {
				PROMOS.add(tweet);
				other = false;
				promoMap.put("Commercial", promoMap.get("Commercial") + 1);
			}

			if (tweetUPPER.contains("HOME") || tweetUPPER.contains("HOUSE")
					|| tweetUPPER.contains("CASA")
					|| tweetUPPER.contains("MY PLACE")
					|| tweetUPPER.contains("RESIDENCE")
					|| tweetUPPER.contains("FIRE")
					|| tweetUPPER.contains("FLOOD")
					|| tweetUPPER.contains("CLAIM")) {
				HOME.add(tweet);
				other = false;
			}
			if (tweetUPPER.contains("BANK") || tweetUPPER.contains("DEPOSIT")
					|| tweetUPPER.contains("LOAN")
					|| tweetUPPER.contains("FINANCES")
					|| tweetUPPER.contains("WITHDRAWL")
					|| tweetUPPER.contains("MONEY")
					|| tweetUPPER.contains("ATM")) {
				BANK.add(tweet);
				other = false;
			}
			if (tweetUPPER.contains("TERM LIFE") || tweetUPPER.contains("LIFE")
					|| tweetUPPER.contains("TERM LIFE")) {
				LIFE.add(tweet);
				other = false;

			}
			if (other == true) {
				OTHER.add(tweet);
				// System.out.println(tweet);
			}

		}
		return tweetMap;
	}

	public void addKey(String key, String[] wordAssociated) {

	}
}
